package com.eduadmin.service;

import com.eduadmin.entity.Teacher;
import com.eduadmin.mapper.TeacherMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TeacherServiceImpl implements ITeacherService {

    private final TeacherMapper teacherMapper;

    @Autowired
    public TeacherServiceImpl(TeacherMapper teacherMapper) {
        this.teacherMapper = teacherMapper;
    }

    @Override
    public void addTeachers(List<Teacher> teachers) {
        teacherMapper.insertTeachers(teachers);
    }

    @Override
    public Teacher getTeacherByTeacherIdcard(String teacherIdcard) {
        return teacherMapper.selectTeacherByIdcard(teacherIdcard);
    }

    @Override
    public List<Teacher> getAllTeachers(Map<String, Object> paraMap) {
        return teacherMapper.selectAllTeachers(paraMap);
    }

    @Override
    public long getAllTotal(Map<String, Object> paraMap) {
        return teacherMapper.selectAllTeacherTotal(paraMap);
    }

    @Override
    public int newAddTeacher(Teacher teacher) {
        return teacherMapper.insertNewAddTeacher(teacher);
    }

    @Override
    public int editTeacher(Teacher teacher) {
        return teacherMapper.insertORupdate(teacher);
    }

    @Override
    public int deleteTeacher(String teacherIdCardString) {
        return teacherMapper.deleteTeacher(teacherIdCardString);
    }

    @Override
    public Teacher getTeacherByTeacherName(String teacherName) {
        return teacherMapper.selectTeacherByName(teacherName);
    }
}
